<script type="text/javascript">
    var root = "__ROOT__", index = "__Index__";</script>
<link rel="stylesheet"
	href="__ROOT__/Public/Plugins/uploadify/uploadify.css" />
<script type="text/javascript"
	src="__ROOT__/Public/Plugins/uploadify/jquery.uploadify-3.1.min.js"></script>
<script type="text/javascript"
	src="__ROOT__/Public/Plugins/uploadify/jquery.jUpload.js"></script>
<script type="text/javascript">
    $(function() {
		$('#show_msg').hide();
        $("#upload1").jUpload({
            trigger_id: "t_upload1",
            uploader: "{:U('uploadify/head_img')}",
            queueID: "upload1-queue",
            formData: {
                "<?php echo session_name(); ?>": "<?php echo session_id(); ?>",
                "savePath": "/Upload/images/names/",
                "saveRule": "time",
                "divId": "img1",
                "thumb": 1,
            },
            success: function(data, info) {
                var img = $("#img1 img");
                if (img.length == 0) {
                    img = $("<img src=\"" + root + data[0]["path"] + "\" alt=\"" + info + "\" style=\"max-height:200px;max-width:300px;\" />")
                    $("#img1").append(img);
                } else {
                    img.attr("src", root + data[0]["path"]);
                }
                $("input[name=pic]").val(data[0]['id']);
                $("input[name=width]").val(data[0]['width']);
                $("input[name=height]").val(data[0]['height']);
            }
        });
    })
function formcheck()
{
    if($("#id").val()==""){
        if($("#photo_1").val()==""){
            $('#show_msg').show();
            return false;
        }
    }
	return true;
}
</script>
<div id="nav" class="mainnav_title">
	<ul>
		<a href="{:U('lists')}">图片广告</a> |
		<a class="on" href="{:U('edit',array('id'=>$lists['id']))}">编辑图片</a>
	</ul>
</div>
<form name="myform" method="post" id="myform"
	action="{:U('advpic/edit')}" onSubmit="return formcheck();">
	<table border="0" cellspacing="0" cellpadding="0" class="table_form"
		width="100%" style="margin:10px 0px 0px 10ox;">
		<tr>
			<th width="10%"><span class="red">*</span>名称:</th>
			<td width="90%"><input type="text" name="title" id="title"
				class="input-text" value="{$lists.title}" /></td>
		</tr>
		<tr>
			<th><span class="red">*</span>广告开始时间</th>
			<td><input name="start_time" type="text" id="start_time"
				value='{$lists.start_time|f_date}' class="input-text calender" /></td>
		</tr>
		<tr>
			<th><span class="red">*</span>广告结束时间</th>
			<td><input name="end_time" type="text" id="end_time"
				value='{$lists.end_time|f_date}' class="input-text calender" /></td>
		</tr>
		<tr>
			<th><span class="red">*</span>展示区域</th>
			<td><volist name="areas" id="vo"> <label><input
				<if condition="$vo.id eq $lists['area_id']">checked="checked"<else /></if>
					id="area_id[]" name="area_id" value="{$vo.id}"
					type="radio">{$vo.names}</label> </volist></td>
		</tr>
		<tr>
			<th><span class="red">*</span>状态：</th>
			<td><label><input name="status" value="1" type="radio"
				<if condition="$lists.status eq '1'">checked="checked"<else /></if>
					>启用</label> <label><input name="status" value="0" type="radio"
				<if condition="$lists.status eq '0'">checked="checked"<else /></if>
					>停用</label></td>
		</tr>

		<tr>
			<th><span class="red">*</span>图片</th>
			<td><div id="img1">
					<img src="{$img.path}" alt="上传成功"
						style="max-height: 200px; max-width: 300px">
				</div>
				<div id="upload1-queue"></div> <input class="isFile" type="hidden"
				id="photo_1" name="pic_front" /> <input data-msg-isFile="请先上传图片"
				class="isFile" id="upload1" name="file_upload1" type="file" /> <a
				class="upload_bt" href="javascript:void(0);" id="t_upload1"
				onclick="$('#show_msg').hide();">点击上传</a><span
				class="Validform_checktip f_left Validform_wrong" id="show_msg">请先上传图片再提交</span>
			</td>
		</tr>
		<tr>
			<th><span class="red">*</span>图片排序</th>
			<td><input name="sort" type="text" id="sort"
				value='{$lists.sort}' /></td>
		</tr>
		<tr>
			<th><span class="red">*</span>图片链接</th>
			<td><input name="url" type="text" id="url" value='{$lists.url}' />
			</td>
			<input type="hidden" class="text" name="id" id="id"
				value="{$lists.id}" />
			<input type="hidden" class="text" name="pic" id="pic"
				value="{$lists.pic}" />
			<input type="hidden" class="text" name="width" id="width"
				value="{$lists.width}" />
			<input type="hidden" class="text" name="height" id="height"
				value="{$lists.height}" />
		</tr>
			<tr>
			<th><span class="red">*</span>归属地区</th>
			<td><select id="areaid" name="areaid">
					<option value="">请选择</option>
					<option value="0471" <if condition="$lists.areaid eq '0471'"> selected="selected" </if> >呼和浩特</option>
					<option value="0470" <if condition="$lists.areaid eq '0470'"> selected="selected" </if>>呼伦贝尔</option>
					<option value="0479" <if condition="$lists.areaid eq '0479'"> selected="selected" </if>>锡林郭勒盟</option>
					<option value="0483" <if condition="$lists.areaid eq '0483'"> selected="selected" </if>>额济纳</option>
			</select></td>
			<input tyep="hidden" id="areaid" name="areaname">
		</tr>
		<tr>
			<td height="100">&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
	</table>
	<div id="btnbox" class="btn">
		<input type="submit" name="submit" value=" 保 存 " class="button">
		<input type="reset" name="reset" value=" 重 置 " class="button">
	</div>
</form>